
#include <stdlib.h>
#include <math.h>

#include "xinit.h"
#include "fractal.h"
#include "sincos.h"
#include "types.h"

#define BYTE(a)     (a&0xff)
#define INDEX(x,y)  (((y)*320)+x)

char *BumpMap;
int BumpA1,BumpA2;

void
IncBump()
{
  BumpA1=((BumpA1+10)&(SINSIZE-1));
  BumpA2=((BumpA2+9)&(SINSIZE-1)); 
}

/*
 * 16bpp bump
 */
void
Bump(XWindow *xw,int framecounter)
{
  int cx,cy,x,y;
  int lx,ly;
  int r,g,b;
  int colx,coly,col;
  word *scr=((word *)xw->virtualscreen)+320;
  byte *bmp=BumpMap+320;

  cx=Cos[BumpA1]+160;
  cy=Sin[BumpA2]+100;

  for(y=1;y<199;y++)
    for(x=0;x<320;x++)
      {
	
	lx=x-cx;
	ly=y-cy;

	if((lx<180)&&(lx>-180)&&(ly<180)&&(ly>-180))
	  {

	    colx=127-abs(lx-*(bmp+1)+*(bmp-1));
	    coly=127-abs(ly-*(bmp+320)+*(bmp-320));
	    if((colx>0)&&(coly>0))
	      {
		col=colx*coly/64;
	    
		r=(col>>3);
		g=(col>>2);
		b=(col>>3);
		
		*(scr)=(word)((r<<11)+(g<<5)+b);
	      }
	  }
	bmp++;
	scr++;
      }
}






